package com.hxm.appGenealogy.config;

import com.alibaba.fastjson.JSON;
import com.hxm.appGenealogy.entity.People;
import com.hxm.appGenealogy.entity.PeopleVo;

import java.util.Map;

public class ParmIntended {

    /**
     * 参数教验;
     * @param o
     * @param parms
     * @return
     */
    public static String parmAnalysis(Object o,String ... parms){
        String string = JSON.toJSONString(o);
        Map<String,Object> mapObject = (Map<String,Object>)JSON.parse(string);
        String [] vars = parms;
        for (String var : vars) {
            //如果不包含的话
            if(!mapObject.containsKey(var)){
                return "缺少参数"+var;
            }
        }
        return null;
    }





    /*删除多余的字段,在次封装实体类;.*/
    public static People removePeopleRequestId(PeopleVo peopleVo){
        String string = JSON.toJSONString(peopleVo);
        Map<String,Object> parse = (Map<String,Object>)JSON.parse(string);
        parse.remove(Constant.myPeopleId);
        parse.remove("code");
        parse.remove("verificationCode");
        parse.remove("tenementId");
        parse.remove("qrPopleId");
        People people = JSON.parseObject(JSON.toJSONString(parse), People.class);
        return people;
    }
}
